﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NIEN_LUAN
{
    public partial class FormChiTietPhieuChi : Form
    {
        private Db.DataContentDataContext db = new NIEN_LUAN.Db.DataContentDataContext();
        private Db.PhieuChiMoRong phieuchi;
        public FormChiTietPhieuChi()
        {
            InitializeComponent();
        }
        public FormChiTietPhieuChi(Db.PhieuChiMoRong model)
        {
            this.phieuchi = model;
            InitializeComponent();
        }

        private void FormChiTietPhieuChi_Load(object sender, EventArgs e)
        {
            if (phieuchi != null)
            {
                var chitietphieunhap = (from m in db.CHITIETPHIEUNHAPs
                                        where m.SoPhieuNhap == phieuchi.SoPhieuNhap
                                        select new Db.ChitietNhapXuat {
                                        DonGia=m.MATHANG.GiaBan??0,
                                        MaChiTiet=m.SoPhieuNhap,
                                        SoLuong=m.SoLuongNhap??0,
                                        TenHang=m.MATHANG.TenHang                                        
                                        
                                        }).ToList();
                this.dataGridView1.AutoGenerateColumns = false;
                this.bsChiTietNhap.DataSource = chitietphieunhap;
                this.dataGridView1.DataSource = bsChiTietNhap;
                this.lbConNo.Text = phieuchi.ConNo.ToString();
                this.lbDaTra.Text = phieuchi.SoTienTra.ToString();
                this.lbNgayNhap.Text = phieuchi.NgayNhap.ToShortDateString();
                this.lbSoPhieuNhap.Text = phieuchi.SoPhieuNhap;
                this.lbTenNhanVienNhap.Text = phieuchi.TenNhanVien;
                this.lbTongTien.Text = phieuchi.SoTienNhap.ToString();
            }
        }

        private void label10_Click(object sender, EventArgs e)
        {

        }

        private void label11_Click(object sender, EventArgs e)
        {

        }

        //private void label9_Click(object sender, EventArgs e)
        //{

        //}

        //private void label8_Click(object sender, EventArgs e)
        //{

        //}
    }
}
